package com.test.daily.leetcode.y2022.m05.day0525.v02;

import java.util.Arrays;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2022/5/25 下午 10:43
 * @version: 1.0
 */
public class Solution {
    public int findSubstringInWraproundString(String p) {
        int[] c = new int[26];
        int k = 0;
        for (int i = 0; i < p.length(); i++) {
            if( i > 0 && ((p.charAt(i) - p.charAt(i-1) + 26)%26 == 1)){
                k++;
            } else {
                k = 1;
            }
            c[p.charAt(i) - 'a'] = Math.max(k, c[p.charAt(i) - 'a']);
        }
        return Arrays.stream(c).sum();
    }
}
